*********************************************************************
*																    *
*Campaign Panel Book Do-File Chapter 2 - media reception frequency	*
*																	*
*********************************************************************



*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
* 1. Simple reception frequency (indices) 
*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++


*-------------------------------------
* Mass media
*-------------------------------------

/* 
Concentrate different modes of reception in indeces to make things clearer.
The question asks for the days in the previous week on which a specific medium was used.
Problem: mean-indices implicitly assume that someone is able to for example read 
all daily newspapers seven days a week. 
It seems more sensible to add the number of days for each medium and concentrate
everything above seven.

Additional problem: 2009 many missings in media reception variables. 2013 the 
question mode was changed, if someone did not give an answer, he was asked to 
explain what exactly this means: whether he really did not want to answer the 
question or whether he really did not use the medium. By a large majority the 
respondents indicated that they used the medium  "0 days" per week. Therefore, 
2013 contains significantly less missing values. 
In the following indices the implicit assumption is that "not specified" is equal
0. Since row-rumbers are calculated and only valid answers are used, the 
addition of a zero does not change the result.
If this assumption were not made, all respondents that even just once have a 
"not specified" answer would be excluded from the analysis. But if a respondent
has "not specified" answer on all modes of reception, he is assigned a missing
value and not a 0. */


**Printmedia Reception


*2009
*Bild (in days)
*Wave 1
		gen a_bild1=.
			replace a_bild1=0 if a_kp1_1720a==100 | a_kp1_1720a==1 			//not applicable for 0 days included
			replace a_bild1=1 if a_kp1_1720a==2 
			replace a_bild1=2 if a_kp1_1720a==3 
			replace a_bild1=3 if a_kp1_1720a==4 
			replace a_bild1=4 if a_kp1_1720a==5 
			replace a_bild1=5 if a_kp1_1720a==6 
			replace a_bild1=6 if a_kp1_1720a==7 
			replace a_bild1=7 if a_kp1_1720a==8 
			replace a_bild1=.a if a_kp1_1720a==. 
			replace a_bild1=. if a_kp1_1720a==99 					// not specified is treated as missing

*Waves 2-7
foreach num of numlist  2/7 {
		gen a_bild`num'=.
			replace a_bild`num'=0 if a_kp`num'_1660a==100 | a_kp`num'_1660a==1			//not applicable for 0 days included
			replace a_bild`num'=1 if  a_kp`num'_1660a==2
			replace a_bild`num'=2 if  a_kp`num'_1660a==3
			replace a_bild`num'=3 if a_kp`num'_1660a==4
			replace a_bild`num'=4 if  a_kp`num'_1660a==5
			replace a_bild`num'=5 if  a_kp`num'_1660a==6
			replace a_bild`num'=6 if  a_kp`num'_1660a==7
			replace a_bild`num'=7 if  a_kp`num'_1660a==8
			replace a_bild`num'=.a if  a_kp`num'_1660a==.
			replace a_bild`num'=. if  a_kp`num'_1660a==99					//not specified is treated as missing
	}
*label Reception Bild-Paper
foreach num of numlist 1/7 {
	lab var a_bild`num' "Rezeption: Bild-Zeitung"
}

*2013

*Bild (in days)
*Wave 1
		gen b_bild1=b_kp1_1721a-1

*Waves 2-7
foreach num of numlist  2/7 {
		gen b_bild`num'= b_kp`num'_1661a-1
		replace b_bild`num'=. if b_bild`num'<0
		}

			
*label Reception Bild-Paper
foreach num of numlist 1/7 {
	lab var b_bild`num' "Rezeption: Bild-Zeitung"
}





**Frankfurter Rundschau (in days)
*2009
*Wave 1
		gen a_fr1=.
			replace a_fr1=0 if a_kp1_1720b==100 | a_kp1_1720b==1 			//not applicable for 0 days included
			replace a_fr1=1 if a_kp1_1720b==2 
			replace a_fr1=2 if a_kp1_1720b==3 
			replace a_fr1=3 if a_kp1_1720b==4 
			replace a_fr1=4 if a_kp1_1720b==5 
			replace a_fr1=5 if a_kp1_1720b==6 
			replace a_fr1=6 if a_kp1_1720b==7 
			replace a_fr1=7 if a_kp1_1720b==8 
			replace a_fr1=.a if a_kp1_1720b==. 
			replace a_fr1=. if a_kp1_1720b==99 					//not specified is treated as missing

*Waves 2-7
foreach num of numlist  2/7 {
		gen a_fr`num'=.
			replace a_fr`num'=0 if a_kp`num'_1660b==100 | a_kp`num'_1660b==1			//not applicable for 0 days included
			replace a_fr`num'=1 if  a_kp`num'_1660b==2
			replace a_fr`num'=2 if  a_kp`num'_1660b==3
			replace a_fr`num'=3 if a_kp`num'_1660b==4
			replace a_fr`num'=4 if  a_kp`num'_1660b==5
			replace a_fr`num'=5 if  a_kp`num'_1660b==6
			replace a_fr`num'=6 if  a_kp`num'_1660b==7
			replace a_fr`num'=7 if  a_kp`num'_1660b==8
			replace a_fr`num'=.a if  a_kp`num'_1660b==.
			replace a_fr`num'=. if  a_kp`num'_1660b==99					//not specified is treated as missing
	}

*label Reception Frankfurter Rundschau
foreach num of numlist 1/7 {
	lab var a_fr`num' "Rezeption: Frankfurter Rundschau"
}



*Frankfurter Rundschau (in days)
*2013
*Wave 1
		gen b_fr1=b_kp1_1721b-1

*Waves 2-7
foreach num of numlist  2/7 {
		gen b_fr`num'= b_kp`num'_1661b-1
		replace b_fr`num'=. if b_fr`num'<0
		}

			
*label Reception Frankfurter-Rundschau
foreach num of numlist 1/7 {
	lab var b_fr`num' "Rezeption: Frankfurter-Rundschau"
}



			
*FAZ (in days)
*2009
*Wave 1
		gen a_faz1=.
			replace a_faz1=0 if a_kp1_1720c==100 | a_kp1_1720c==1 			//not applicable for 0 days included
			replace a_faz1=1 if a_kp1_1720c==2 
			replace a_faz1=2 if a_kp1_1720c==3 
			replace a_faz1=3 if a_kp1_1720c==4 
			replace a_faz1=4 if a_kp1_1720c==5 
			replace a_faz1=5 if a_kp1_1720c==6 
			replace a_faz1=6 if a_kp1_1720c==7 
			replace a_faz1=7 if a_kp1_1720c==8 
			replace a_faz1=.a if a_kp1_1720c==. 
			replace a_faz1=. if a_kp1_1720c==99 					//not specified is treated as missing

*Waves 2-7
foreach num of numlist  2/7 {
		gen a_faz`num'=.
			replace a_faz`num'=0 if a_kp`num'_1660c==100 | a_kp`num'_1660c==1			//not applicable for 0 days included
			replace a_faz`num'=1 if  a_kp`num'_1660c==2
			replace a_faz`num'=2 if  a_kp`num'_1660c==3
			replace a_faz`num'=3 if a_kp`num'_1660c==4
			replace a_faz`num'=4 if  a_kp`num'_1660c==5
			replace a_faz`num'=5 if  a_kp`num'_1660c==6
			replace a_faz`num'=6 if  a_kp`num'_1660c==7
			replace a_faz`num'=7 if  a_kp`num'_1660c==8
			replace a_faz`num'=.a if  a_kp`num'_1660c==.
			replace a_faz`num'=. if  a_kp`num'_1660c==99					//not specified is treated as missing
	}

*label Reception Frankfurter Allgemeine Zeitung
foreach num of numlist 1/7 {
	lab var a_faz`num' "Rezeption: Frankfurter Allgemeine Zeitung"
}


			
*FAZ (in days)
*2013
*Wave 1
		gen b_faz1=b_kp1_1721c-1

*Waves 2-7
foreach num of numlist  2/7 {
		gen b_faz`num'= b_kp`num'_1661c-1
		replace b_faz`num'=. if b_faz`num'<0
		}

			
*label Reception FAZ
foreach num of numlist 1/7 {
	lab var b_faz`num' "Rezeption: FAZ"
}





*Süddeutsche Zeitung (in days)
*2009
*Wave 1
		gen a_sz1=.
			replace a_sz1=0 if a_kp1_1720d==100 | a_kp1_1720d==1 			//not applicable for 0 days included
			replace a_sz1=1 if a_kp1_1720d==2 
			replace a_sz1=2 if a_kp1_1720d==3 
			replace a_sz1=3 if a_kp1_1720d==4 
			replace a_sz1=4 if a_kp1_1720d==5 
			replace a_sz1=5 if a_kp1_1720d==6 
			replace a_sz1=6 if a_kp1_1720d==7 
			replace a_sz1=7 if a_kp1_1720d==8 
			replace a_sz1=.a if a_kp1_1720d==. 
			replace a_sz1=. if a_kp1_1720d==99 					//not specified is treated as missing

*Waves 2-7
foreach num of numlist  2/7 {
		gen a_sz`num'=.
			replace a_sz`num'=0 if a_kp`num'_1660d==100 | a_kp`num'_1660d==1			//not applicable for 0 days included
			replace a_sz`num'=1 if  a_kp`num'_1660d==2
			replace a_sz`num'=2 if  a_kp`num'_1660d==3
			replace a_sz`num'=3 if a_kp`num'_1660d==4
			replace a_sz`num'=4 if  a_kp`num'_1660d==5
			replace a_sz`num'=5 if  a_kp`num'_1660d==6
			replace a_sz`num'=6 if  a_kp`num'_1660d==7
			replace a_sz`num'=7 if  a_kp`num'_1660d==8
			replace a_sz`num'=.a if  a_kp`num'_1660d==.
			replace a_sz`num'=. if  a_kp`num'_1660d==99					//not specified is treated as missing
	}

*label Reception Südeutsche Zeitung
foreach num of numlist 1/7 {
	lab var a_sz`num' "Rezeption: Süddeutsche Zeitung"
}



*Süddeutsche Zeitung (in days)
*2013
*Wave 1
		gen b_sz1=b_kp1_1721d-1

*Waves 2-7
foreach num of numlist  2/7 {
		gen b_sz`num'= b_kp`num'_1661d-1
		replace b_sz`num'=. if b_sz`num'<0
		}

			
*label Reception FAZ
foreach num of numlist 1/7 {
	lab var b_sz`num' "Rezeption:Süddeutsche Zeitung"
}






*TAZ (in days)
*2009
*Wave 1
		gen a_taz1=.
			replace a_taz1=0 if a_kp1_1720e==100 | a_kp1_1720e==1 			//not applicable for 0 days included
			replace a_taz1=1 if a_kp1_1720e==2 
			replace a_taz1=2 if a_kp1_1720e==3 
			replace a_taz1=3 if a_kp1_1720e==4 
			replace a_taz1=4 if a_kp1_1720e==5 
			replace a_taz1=5 if a_kp1_1720e==6 
			replace a_taz1=6 if a_kp1_1720e==7 
			replace a_taz1=7 if a_kp1_1720e==8 
			replace a_taz1=.a if a_kp1_1720e==. 
			replace a_taz1=. if a_kp1_1720e==99 					//not specified is treated as missing

*Waves 2-7
foreach num of numlist  2/7 {
		gen a_taz`num'=.
			replace a_taz`num'=0 if a_kp`num'_1660e==100 | a_kp`num'_1660e==1			//not applicable for 0 days included
			replace a_taz`num'=1 if  a_kp`num'_1660e==2
			replace a_taz`num'=2 if  a_kp`num'_1660e==3
			replace a_taz`num'=3 if a_kp`num'_1660e==4
			replace a_taz`num'=4 if  a_kp`num'_1660e==5
			replace a_taz`num'=5 if  a_kp`num'_1660e==6
			replace a_taz`num'=6 if  a_kp`num'_1660e==7
			replace a_taz`num'=7 if  a_kp`num'_1660e==8
			replace a_taz`num'=.a if  a_kp`num'_1660e==.
			replace a_taz`num'=. if  a_kp`num'_1660e==99					//not specified is treated as missing
	}

*label Reception die tageszeitung (taz)
foreach num of numlist 1/7 {
	lab var a_taz`num' "Rezeption: die tageszeitung (taz)"
}




*TAZ  (in days)
*2013
*Wave 1
		gen b_taz1=b_kp1_1721e-1

*Waves 2-7
foreach num of numlist  2/7 {
		gen b_taz`num'= b_kp`num'_1661e-1
		replace b_taz`num'=. if b_taz`num'<0
		}

			
*label Reception FAZ
foreach num of numlist 1/7 {
	lab var b_taz`num' "Rezeption:TAZ"
}






*Die Welt (in days)
*2009
*Wave 1
		gen a_welt1=.
			replace a_welt1=0 if a_kp1_1720f==100 | a_kp1_1720f==1 			//not applicable for 0 days included
			replace a_welt1=1 if a_kp1_1720f==2 
			replace a_welt1=2 if a_kp1_1720f==3 
			replace a_welt1=3 if a_kp1_1720f==4 
			replace a_welt1=4 if a_kp1_1720f==5 
			replace a_welt1=5 if a_kp1_1720f==6 
			replace a_welt1=6 if a_kp1_1720f==7 
			replace a_welt1=7 if a_kp1_1720f==8 
			replace a_welt1=.a if a_kp1_1720f==. 
			replace a_welt1=. if a_kp1_1720f==99 					//not specified is treated as missing

*Waves 2-7
foreach num of numlist  2/7 {
		gen a_welt`num'=.
			replace a_welt`num'=0 if a_kp`num'_1660f==100 | a_kp`num'_1660f==1			//not applicable for 0 days included
			replace a_welt`num'=1 if  a_kp`num'_1660f==2
			replace a_welt`num'=2 if  a_kp`num'_1660f==3
			replace a_welt`num'=3 if a_kp`num'_1660f==4
			replace a_welt`num'=4 if  a_kp`num'_1660f==5
			replace a_welt`num'=5 if  a_kp`num'_1660f==6
			replace a_welt`num'=6 if  a_kp`num'_1660f==7
			replace a_welt`num'=7 if  a_kp`num'_1660f==8
			replace a_welt`num'=.a if  a_kp`num'_1660f==.
			replace a_welt`num'=. if  a_kp`num'_1660f==99					//not specified is treated as missing
	}


*label Reception Die Welt
foreach num of numlist 1/7 {
	lab var a_welt`num' "Rezeption: Die Welt"
}





*Die Welt  (in days)
*2013
*Wave 1
		gen b_welt1=b_kp1_1721f-1

*Waves 2-7
foreach num of numlist  2/7 {
		gen b_welt`num'= b_kp`num'_1661f-1
		replace b_welt`num'=. if b_welt`num'<0
		}

			
*label Reception FAZ
foreach num of numlist 1/7 {
	lab var b_welt`num' "Rezeption:Die Welt"
}




* Daily newspapers: 
/*
1. national quality newspapers, 
2. Bildzeitung,
3. other dailies (mainly regional papers)
*/
foreach x in a b {	
forvalues num=1/7 {	
egen `x'_paper`num' = rowtotal(`x'_sz`num' `x'_faz`num' `x'_fr`num' ///
	`x'_taz`num' `x'_welt`num'), missing
replace `x'_paper`num' = 7 if `x'_paper`num'>7 & `x'_paper`num'~=.
replace `x'_paper`num' = `x'_paper`num'/7
lab var `x'_paper`num' "Daily paper"
}
}


fre b_bild2		//Bildzeitung already coded
foreach x in a b {
forvalues num=1/7 {
replace `x'_bild`num' = `x'_bild`num'/7
}
}

lookfor "andere Tageszeitung"

foreach year in a {
gen `year'_paper_and1= `year'_kp1_1720g-1 ///
	if `year'_kp1_1720g<=8
replace `year'_paper_and1 = 0 if `year'_kp1_1720g==100
replace `year'_paper_and1 = . if `year'_kp1_1720g==99
replace `year'_paper_and1 = `year'_paper_and1/7
}


foreach year in b {
gen `year'_paper_and1= `year'_kp1_1721g-1 ///
	if `year'_kp1_1721g<=8
replace `year'_paper_and1 = 0 if `year'_kp1_1721g==100
replace `year'_paper_and1 = . if `year'_kp1_1721g==99
replace `year'_paper_and1 = `year'_paper_and1/7
}


tab a_kp1_1720g a_paper_and1, m


foreach year in a {
foreach wave of numlist 2/7 {
gen `year'_paper_and`wave' = `year'_kp`wave'_1660g-1 ///
	if `year'_kp`wave'_1660g<=8
replace `year'_paper_and`wave' = 0 if `year'_kp`wave'_1660g==100
replace `year'_paper_and`wave' = . if `year'_kp`wave'_1660g==99
replace `year'_paper_and`wave' = `year'_paper_and`wave'/7
}
} 

foreach year in b {
foreach wave of numlist 2/7 {
gen `year'_paper_and`wave' = `year'_kp`wave'_1661g-1 ///
	if `year'_kp`wave'_1661g<=8
replace `year'_paper_and`wave' = 0 if `year'_kp`wave'_1661g==100
replace `year'_paper_and`wave' = . if `year'_kp`wave'_1661g==99
replace `year'_paper_and`wave' = `year'_paper_and`wave'/7
}
} 


tab a_kp2_1660g a_paper_and2, m

mean a_paper2 a_bild2 a_paper_and2  





				
**TV-usage
*Tagesschau (news)
*2009
*Wave 1
gen a_tagesschau1=.
	replace a_tagesschau1=0 if a_kp1_1740a==100 | a_kp1_1740a==1
	replace a_tagesschau1=1 if a_kp1_1740a==2
	replace a_tagesschau1=2 if a_kp1_1740a==3
	replace a_tagesschau1=3 if a_kp1_1740a==4
	replace a_tagesschau1=4 if a_kp1_1740a==5
	replace a_tagesschau1=5 if a_kp1_1740a==6
	replace a_tagesschau1=6 if a_kp1_1740a==7
	replace a_tagesschau1=7 if a_kp1_1740a==8
	replace a_tagesschau1=.a if a_kp1_1740a==.
	replace a_tagesschau1=. if a_kp1_1740a==99 & a_tagesschau1!=.a

*Waves 2-7
foreach num of numlist  2/7 {
		gen a_tagesschau`num'=.
			replace a_tagesschau`num'=0 if a_kp`num'_1680a==100 | a_kp`num'_1680a==1			//not applicable for 0 days included
			replace a_tagesschau`num'=1 if  a_kp`num'_1680a==2
			replace a_tagesschau`num'=2 if  a_kp`num'_1680a==3
			replace a_tagesschau`num'=3 if a_kp`num'_1680a==4
			replace a_tagesschau`num'=4 if  a_kp`num'_1680a==5
			replace a_tagesschau`num'=5 if  a_kp`num'_1680a==6
			replace a_tagesschau`num'=6 if  a_kp`num'_1680a==7
			replace a_tagesschau`num'=7 if  a_kp`num'_1680a==8
			replace a_tagesschau`num'=.a if  a_kp`num'_1680a==.
			replace a_tagesschau`num'=. if  a_kp`num'_1680a==99					//not specified is treated as missing
	}
*label TV-usage: Tagesschau or Tagesthemen
foreach num of numlist 1/7 {
	lab var a_tagesschau`num' "TV-Nutzung: tagesschau oder Tagesthemen"
}




	
**TV-usage
*2013
* Tagesschau/Tagesthemen (news)
*Wave 1
gen b_tagesschau1=b_kp1_1741a-1

*Waves 2-7
foreach num of numlist  2/7 {
		gen b_tagesschau`num'= b_kp`num'_1681a-1
		replace b_tagesschau`num'=. if b_tagesschau`num'<0
		}

			
*label reception 
foreach num of numlist 1/7 {
	lab var b_tagesschau`num' "Rezeption:Tagesschau/Tagesthemen"

}








*Heute Journal (news)
*2009
*Wave 1
gen a_heute1=.
	replace a_heute1=0 if a_kp1_1740b==100 | a_kp1_1740b==1
	replace a_heute1=1 if a_kp1_1740b==2
	replace a_heute1=2 if a_kp1_1740b==3
	replace a_heute1=3 if a_kp1_1740b==4
	replace a_heute1=4 if a_kp1_1740b==5
	replace a_heute1=5 if a_kp1_1740b==6
	replace a_heute1=6 if a_kp1_1740b==7
	replace a_heute1=7 if a_kp1_1740b==8
	replace a_heute1=.a if a_kp1_1740b==.
	replace a_heute1=. if a_kp1_1740b==99

*Waves 2-7
foreach num of numlist  2/7 {
		gen a_heute`num'=.
			replace a_heute`num'=0 if a_kp`num'_1680b==100 | a_kp`num'_1680b==1			//not applicable for 0 days included
			replace a_heute`num'=1 if  a_kp`num'_1680b==2
			replace a_heute`num'=2 if  a_kp`num'_1680b==3
			replace a_heute`num'=3 if a_kp`num'_1680b==4
			replace a_heute`num'=4 if  a_kp`num'_1680b==5
			replace a_heute`num'=5 if  a_kp`num'_1680b==6
			replace a_heute`num'=6 if  a_kp`num'_1680b==7
			replace a_heute`num'=7 if  a_kp`num'_1680b==8
			replace a_heute`num'=.a if  a_kp`num'_1680b==.
			replace a_heute`num'=. if  a_kp`num'_1680b==99					//not specified is treated as missing
	}

*label TV-usage: Heute or Heute-Journal (news)
foreach num of numlist 1/7 {
	lab var a_heute`num' "TV-Nutzung: heute oder heute-Journal"
}




*Heute/Heute-Journal
*Wave 1
gen b_heute1=b_kp1_1741b-1

*Waves 2-7
foreach num of numlist 2/7 {
		gen b_heute`num'= b_kp`num'_1681b-1
		replace b_heute`num'=. if b_heute`num'<0
		}

			
*label Reception 
foreach num of numlist 1/7 {
	lab var b_heute`num' "Rezeption:Heute/Heute-Journal"
}










	
*RTL Aktuell (news)
*2009
*Wave 1
gen a_rtl1=.
	replace a_rtl1=0 if a_kp1_1740c==100 | a_kp1_1740c==1
	replace a_rtl1=1 if a_kp1_1740c==2
	replace a_rtl1=2 if a_kp1_1740c==3
	replace a_rtl1=3 if a_kp1_1740c==4
	replace a_rtl1=4 if a_kp1_1740c==5
	replace a_rtl1=5 if a_kp1_1740c==6
	replace a_rtl1=6 if a_kp1_1740c==7
	replace a_rtl1=7 if a_kp1_1740c==8
	replace a_rtl1=.a if a_kp1_1740c==.
	replace a_rtl1=. if a_kp1_1740c==99

*Waves 2-7
foreach num of numlist  2/7 {
		gen a_rtl`num'=.
			replace a_rtl`num'=0 if a_kp`num'_1680c==100 | a_kp`num'_1680c==1			//not applicable for 0 days included
			replace a_rtl`num'=1 if  a_kp`num'_1680c==2
			replace a_rtl`num'=2 if  a_kp`num'_1680c==3
			replace a_rtl`num'=3 if a_kp`num'_1680c==4
			replace a_rtl`num'=4 if  a_kp`num'_1680c==5
			replace a_rtl`num'=5 if  a_kp`num'_1680c==6
			replace a_rtl`num'=6 if  a_kp`num'_1680c==7
			replace a_rtl`num'=7 if  a_kp`num'_1680c==8
			replace a_rtl`num'=.a if  a_kp`num'_1680c==.
			replace a_rtl`num'=. if  a_kp`num'_1680c==99					//not specified is treated as missing
	}

*label TV-usage: RTL Aktuell
foreach num of numlist 1/7 {
	lab var a_rtl`num' "TV-Nutzung: RTL Aktuell"
}



	
*RTL Aktuell
*Wave 1
gen b_rtl1=b_kp1_1741c-1

*Waves 2-7
foreach num of numlist  2/7 {
		gen b_rtl`num'= b_kp`num'_1681c-1
		replace b_rtl`num'=. if b_rtl`num'<0
		}

			
*label Reception 
foreach num of numlist 1/7 {
	lab var b_rtl`num' "Rezeption:RTL Aktuell"
}










*Sat1 news
*2009
*Wave 1
gen a_sat1=.
	replace a_sat1=0 if a_kp1_1740d==100 | a_kp1_1740d==1
	replace a_sat1=1 if a_kp1_1740d==2
	replace a_sat1=2 if a_kp1_1740d==3
	replace a_sat1=3 if a_kp1_1740d==4
	replace a_sat1=4 if a_kp1_1740d==5
	replace a_sat1=5 if a_kp1_1740d==6
	replace a_sat1=6 if a_kp1_1740d==7
	replace a_sat1=7 if a_kp1_1740d==8
	replace a_sat1=.a if a_kp1_1740d==.
	replace a_sat1=. if a_kp1_1740d==99


*Waves 2-7
foreach num of numlist  2/7 {
		gen a_sat`num'=.
			replace a_sat`num'=0 if a_kp`num'_1680d==100 | a_kp`num'_1680d==1			//not applicable for 0 days included
			replace a_sat`num'=1 if  a_kp`num'_1680d==2
			replace a_sat`num'=2 if  a_kp`num'_1680d==3
			replace a_sat`num'=3 if a_kp`num'_1680d==4
			replace a_sat`num'=4 if  a_kp`num'_1680d==5
			replace a_sat`num'=5 if  a_kp`num'_1680d==6
			replace a_sat`num'=6 if  a_kp`num'_1680d==7
			replace a_sat`num'=7 if  a_kp`num'_1680d==8
			replace a_sat`num'=.a if  a_kp`num'_1680d==.
			replace a_sat`num'=. if  a_kp`num'_1680d==99					//not specified is treated as missing
	}

*label TV-usage: sat. 1 news
foreach num of numlist 1/7 {
	lab var a_sat`num' "TV-Nutzung: Sat. 1 Nachrichten"
}



			
*Sat1 news
*Wave 1
gen b_sat1=b_kp1_1741d-1

*Waves 2-7
foreach num of numlist  2/7 {
		gen b_sat`num'= b_kp`num'_1681d-1
		replace b_sat`num'=. if b_sat`num'<0
		}

			
*label Reception 
foreach num of numlist 1/7 {
	lab var b_sat`num' "Rezeption:Sat1 Nachrichten"
}










* TV-news 
foreach x in a b {
foreach num of numlist 1/7 {
egen `x'_oeff`num' = rowtotal(`x'_tagesschau`num' `x'_heute`num'), missing
replace `x'_oeff`num' = 7 if `x'_oeff`num'>7 & `x'_oeff`num'!=.
lab var `x'_oeff`num' "TV news (public)" 
replace `x'_oeff`num' = `x'_oeff`num'/7
}
}


forvalues num=1/7 {	
egen a_privat`num' = rowtotal(a_rtl`num' a_sat`num'), missing
replace a_privat`num' = 7 if a_privat`num'>7 & a_privat`num'!=.
replace a_privat`num' = a_privat`num'/7
egen b_privat`num' = rowtotal(b_rtl`num' b_sat`num'), missing
replace b_privat`num' = 7 if b_privat`num'>7 & b_privat`num'~=.
replace b_privat`num' = b_privat`num'/7
lab var a_privat`num' "TV news (private)" 
lab var b_privat`num' "TV news (private)"
}

fre ?_privat*





		
*Talking about politics (in days)
*2009
foreach num of numlist 1/7 {
	gen a_gesprpol`num'=.
		replace a_gesprpol`num'= a_kp`num'_1930
		replace a_gesprpol`num'=.a if a_kp`num'_1930==.		//W2 starter
		replace a_gesprpol`num'=. if a_kp`num'_1930==99		// not specified 
}

*label talking about politics (in days)
foreach num of numlist 1/7 {
	lab var a_gesprpol`num' "Gespräche über Politik"
}




	
	
*Talking about politics (in days)
*2013
/// a friends b partner c relatives d co-workers e acquaintances

*Wave 1
local suffix "a b c d e" 			
foreach x of local suffix  {
	gen b_gesprpol_`x'1=.
		replace b_gesprpol_`x'1= b_kp1_1931`x'-1
		replace b_gesprpol_`x'1=. if b_kp1_1931`x'<0		// not specified  
}




*beginning at wave 2
local suffix "a b c d e" 			
foreach num of numlist 2/7 {
foreach x of local suffix  {
	gen b_gesprpol_`x'`num'=.
		replace b_gesprpol_`x'`num'= b_kp`num'_1932`x'-1
		replace b_gesprpol_`x'`num'=. if b_kp`num'_1932`x'<0		// not specified 
}
}

*label talking about politics (in days)
foreach num of numlist 1/7 {
	lab var b_gesprpol_a`num' "Politische Gespräche, aktuell: Freunde"
	lab var b_gesprpol_b`num' "Politische Gespräche, aktuell: Partner"
	lab var b_gesprpol_c`num' "Politische Gespräche, aktuell: Verwandte"
	lab var b_gesprpol_d`num' "Politische Gespräche, aktuell: Arbeitskollegen"
	lab var b_gesprpol_e`num' "Politische Gespräche, aktuell: Bekannte"
}


* political talks
forvalues num=1/7 {	
gen a_talk`num' = a_kp`num'_1930/7 if  a_kp`num'_1930~=99		
egen b_talk`num' = rowtotal(b_gesprpol_a`num'-b_gesprpol_e`num'), missing
replace b_talk`num' = 7 if b_talk`num'>7 & b_talk`num'~=.
replace b_talk`num' = b_talk`num'/7
lab var a_talk`num' "Political talk" 
lab var b_talk`num' "Political talk"
}


fre ?_talk*
list b_gesprpol_a1-b_gesprpol_e1 b_talk1



* Newsmagazines (print)
/* Attention: newsmagazines are only published/released once a week. 
Index therefore indicates how many magazines are read each week.
Max = 4 */



**Newsmagazines
*2009
*Wave 1
local suffix "a b c d "		//a=Spiegel b=Focus c=Zeit d=Stern
foreach num1 of numlist 1 {
foreach x of local suffix {
	gen a_Nachrichtenmagazin_`x'_`num1'=.
	replace a_Nachrichtenmagazin_`x'_`num1'=1 if a_kp`num1'_1760`x'==1		//yes
	replace a_Nachrichtenmagazin_`x'_`num1'=0 if a_kp`num1'_1760`x'==2		//no
	replace a_Nachrichtenmagazin_`x'_`num1'=.a if a_w1!=1								//.a=W2 starter .=not specified and not applicable
	}
}

*Waves 2-7
local suffix "a b c d "		//a=Spiegel b=Focus c=Zeit d=Stern
foreach num1 of numlist 2 3 4 5 6 7  {
foreach x of local suffix {
	gen a_Nachrichtenmagazin_`x'_`num1'=.
	replace a_Nachrichtenmagazin_`x'_`num1'=1 if a_kp`num1'_1700`x'==1		//yes
	replace a_Nachrichtenmagazin_`x'_`num1'=0 if a_kp`num1'_1700`x'==2		//no
	tab a_Nachrichtenmagazin_`x'_`num1',m																//.=not specified and not applicable
	}
}
**label newsmagazines in general
foreach num1 of numlist 1/7 {
	lab var a_Nachrichtenmagazin_a_`num1' "Nachrichtenmagazin: Spiegel"
	lab var a_Nachrichtenmagazin_b_`num1' "Nachrichtenmagazin: Focus"
	lab var a_Nachrichtenmagazin_c_`num1' "Nachrichtenmagazin: Zeit"
	lab var a_Nachrichtenmagazin_d_`num1' "Nachrichtenmagazin: Stern"
}



	
*******************************
**Newsmagazines
*2013
*Wave 1
local suffix "a b c d "		//a=Spiegel b=Focus c=Zeit d=Stern
local uffix "a b c"			//a= online b=print c=do not read it
foreach num1 of numlist 1 {
foreach x of local suffix {
foreach y of local uffix {
	gen b_Nachrichtenmagazin_`x'`y'_`num1'=.
	replace b_Nachrichtenmagazin_`x'`y'_`num1'=1 if b_kp`num1'_1760`x'`y'==1		//yes
	replace b_Nachrichtenmagazin_`x'`y'_`num1'=0 if b_kp`num1'_1760`x'`y'==2		//no
	replace b_Nachrichtenmagazin_`x'`y'_`num1'=. if b_kp`num1'_1760`x'`y'==-99	//no
	tab b_Nachrichtenmagazin_`x'`y'_`num1',m
	}
}
}

*Waves 2-7
local suffix "a b c d "		//a=Spiegel b=Focus c=Zeit d=Stern
local uffix "a b c"			//a= online b=print c=do not read it
foreach num1 of numlist 2 3 4 5 6 7  {
foreach x of local suffix {
foreach y of local uffix {
	gen b_Nachrichtenmagazin_`x'`y'_`num1'=.
	replace b_Nachrichtenmagazin_`x'`y'_`num1'=1 if b_kp`num1'_1700`x'`y'==1		//yes
	replace b_Nachrichtenmagazin_`x'`y'_`num1'=0 if b_kp`num1'_1700`x'`y'==2		//no
	tab b_Nachrichtenmagazin_`x'`y'_`num1',m																//.= not specified and not applicable
	}
}
}

*label newsmagazines
foreach num1 of numlist 1/7  {
	lab var b_Nachrichtenmagazin_aa_`num1' "Nachrichtenmagazin: Spiegel, lese Online-Ausgabe"
	lab var b_Nachrichtenmagazin_ab_`num1' "Nachrichtenmagazin: Spiegel, lese gedruckte Ausgabe"
	lab var b_Nachrichtenmagazin_ac_`num1' "Nachrichtenmagazin: Spiegel, lese ich nicht"
	lab var b_Nachrichtenmagazin_ba_`num1' "Nachrichtenmagazin: Focus, lese Online-Ausgabe"
	lab var b_Nachrichtenmagazin_bb_`num1' "Nachrichtenmagazin: Focus, lese gedruckte Ausgabe"
	lab var b_Nachrichtenmagazin_bc_`num1' "Nachrichtenmagazin: Focus, lese ich nicht"
	lab var b_Nachrichtenmagazin_ca_`num1' "Nachrichtenmagazin: Die Zeit, lese Online-Ausgabe"
	lab var b_Nachrichtenmagazin_cb_`num1' "Nachrichtenmagazin: Die Zeit, lese gedruckte Ausgabe"
	lab var b_Nachrichtenmagazin_cc_`num1' "Nachrichtenmagazin: Die Zeit, lese ich nicht"
	lab var b_Nachrichtenmagazin_da_`num1' "Nachrichtenmagazin: Stern, lese Online-Ausgabe"
	lab var b_Nachrichtenmagazin_db_`num1' "Nachrichtenmagazin: Stern, lese gedruckte Ausgabe"
	lab var b_Nachrichtenmagazin_dc_`num1' "Nachrichtenmagazin: Stern, lese ich nicht"
}










forvalues welle=1/7 {
egen a_magazine`welle' = rowtotal(a_Nachrichtenmagazin_?_`welle'), missing
replace a_magazine`welle' = a_magazine`welle'/4
egen b_magazine`welle' = rowtotal(b_Nachrichtenmagazin_?b_`welle'), missing
replace b_magazine`welle' = b_magazine`welle'/4
lab var a_magazine`welle' "Weekly paper" 
lab var b_magazine`welle' "Weekly paper"
}

fre a_Nachrichtenmagazin_?_1
fre a_magazine?
fre b_magazine?






*Political internet usage
*2009
foreach num1 of numlist 2 3 4 5 6 7 {
	gen a_polinter`num1'=.
	replace a_polinter`num1'=a_kp`num1'_1600-1
	replace a_polinter`num1'=0 if a_kp`num1'_1600==101 | a_kp`num1'_1600==100
	replace a_polinter`num1'=. if a_kp`num1'_1600==99 //.=kA 
	lab var a_polinter`num1' "Internetnutzung, politisch aktuell"
	}



*Political internet usage
*2013
foreach num1 of numlist 2 3 4 5 6 7 {
	gen b_polinter`num1'=.
	replace b_polinter`num1'=b_kp`num1'_1600-1
	replace b_polinter`num1'=. if b_kp`num1'_1600<0	
	lab var b_polinter`num1' "Internetnutzung, politisch aktuell"
	}



* Political internet usage
fre ?_polinter?
sum ?_polinter?

foreach var of varlist ?_polinter? {
replace `var' = `var'/7
}

* Index campaign contact
/* The number of contacts is counted. One contact is a contact with a specific
party in a specific way. Example: person A and B have two party contacts each. 
Person A had contact with the SPD via a campaign rally and via a TV-ad. Person B
has seen one poster each from the CDU and from the FDP and therefore also had two
contacts. Based on the chosen definition, both persons experienced the same number
of contacts.
Precoded variables parteikon_ only indicate whether at least one contact happened 
or not (dummy), but in the end we require a count variable.

2009 and 2013 slighly differing ways of summarizing the possible ways of contact.
2013 = summary contains flyer, email, sms in one item, but this is not the case for 2009;
this has to be taken into account

Since comparability between the years is the goal, only those kinds of contact
were utilized which were measuren in both years.*/




*Party contacts, kind by party
*2009
local letter "a b c d e f g h k"						//kind of party contact
foreach num1 of numlist 2 3 4 5 6 7 {		//Waves
foreach num2 of numlist 1 2 3 4 5 {			//Parties (1=Union, 2=SPD, 3=FDP, 4=Gru 5=Linke)
	foreach x of local letter {
		gen a_parteikon_`x'_`num2'_`num1'=.
		replace a_parteikon_`x'_`num2'_`num1'=a_kp`num1'_420`x'_`num2'
		replace a_parteikon_`x'_`num2'_`num1'=. if a_kp`num1'_420`x'_`num2'==100 | a_kp`num1'_420`x'_`num2'==101			//both "does not apply"
		}
	}
}
*label party contacts, kind by party
foreach num of numlist 2 3 4 5 6 7 {		//Waves
	label var a_parteikon_a_1_`num' "Parteikontakt mit Union: Kundgebung"
	label var a_parteikon_b_1_`num' "Parteikontakt mit Union: Email/SMS"
	label var a_parteikon_c_1_`num' "Parteikontakt mit Union: Flugblätter"
	label var a_parteikon_d_1_`num' "Parteikontakt mit Union: Wahlwerbung, Fernsehen"
	label var a_parteikon_e_1_`num' "Parteikontakt mit Union: Wahlwerbung, Radio"
	label var a_parteikon_f_1_`num'  "Parteikontakt mit Union: Wahlanzeigen"
	label var a_parteikon_g_1_`num' "Parteikontakt mit Union: Wahlplakate"
	label var a_parteikon_h_1_`num' "Parteikontakt mit Union: Wahlkampfstand"
	label var a_parteikon_k_1_`num' "Parteikontakt mit Union: Website"
	label var a_parteikon_a_2_`num' "Parteikontakt mit SPD: Kundgebung"
	label var a_parteikon_b_2_`num' "Parteikontakt mit SPD: Email/SMS"
	label var a_parteikon_c_2_`num' "Parteikontakt mit SPD: Flugblätter"
	label var a_parteikon_d_2_`num' "Parteikontakt mit SPD: Wahlwerbung, Fernsehen"
	label var a_parteikon_e_2_`num' "Parteikontakt mit SPD: Wahlwerbung, Radio"
	label var a_parteikon_f_2_`num'  "Parteikontakt mit SPD: Wahlanzeigen"
	label var a_parteikon_g_2_`num' "Parteikontakt mit SPD: Wahlplakate"
	label var a_parteikon_h_2_`num' "Parteikontakt mit SPD: Wahlkampfstand"
	label var a_parteikon_k_2_`num' "Parteikontakt mit SPD: Website"
	label var a_parteikon_a_3_`num' "Parteikontakt mit FDP: Kundgebung"
	label var a_parteikon_b_3_`num' "Parteikontakt mit FDP: Email/SMS"
	label var a_parteikon_c_3_`num' "Parteikontakt mit FDP: Flugblätter"
	label var a_parteikon_d_3_`num' "Parteikontakt mit FDP: Wahlwerbung, Fernsehen"
	label var a_parteikon_e_3_`num' "Parteikontakt mit FDP: Wahlwerbung, Radio"
	label var a_parteikon_f_3_`num'  "Parteikontakt mit FDP: Wahlanzeigen"
	label var a_parteikon_g_3_`num' "Parteikontakt mit FDP: Wahlplakate"
	label var a_parteikon_h_3_`num' "Parteikontakt mit FDP: Wahlkampfstand"
	label var a_parteikon_k_3_`num' "Parteikontakt mit FDP: Website"
	label var a_parteikon_a_4_`num' "Parteikontakt mit Grüne Kundgebung"
	label var a_parteikon_b_4_`num' "Parteikontakt mit Grüne Email/SMS"
	label var a_parteikon_c_4_`num' "Parteikontakt mit Grüne Flugblätter"
	label var a_parteikon_d_4_`num' "Parteikontakt mit Grüne Wahlwerbung, Fernsehen"
	label var a_parteikon_e_4_`num' "Parteikontakt mit Grüne Wahlwerbung, Radio"
	label var a_parteikon_f_4_`num' "Parteikontakt mit Grüne Wahlanzeigen"
	label var a_parteikon_g_4_`num' "Parteikontakt mit Grüne Wahlplakate"
	label var a_parteikon_h_4_`num' "Parteikontakt mit Grüne Wahlkampfstand"
	label var a_parteikon_k_4_`num' "Parteikontakt mit Grüne Website"
	label var a_parteikon_a_5_`num' "Parteikontakt mit Linke: Kundgebung"
	label var a_parteikon_b_5_`num' "Parteikontakt mit Linke: Email/SMS"
	label var a_parteikon_c_5_`num' "Parteikontakt mit Linke: Flugblätter"
	label var a_parteikon_d_5_`num' "Parteikontakt mit Linke: Wahlwerbung, Fernsehen"
	label var a_parteikon_e_5_`num' "Parteikontakt mit Linke: Wahlwerbung, Radio"
	label var a_parteikon_f_5_`num'  "Parteikontakt mit Linke: Wahlanzeigen"
	label var a_parteikon_g_5_`num' "Parteikontakt mit Linke: Wahlplakate"
	label var a_parteikon_h_5_`num' "Parteikontakt mit Linke: Wahlkampfstand"
	label var a_parteikon_k_5_`num' "Parteikontakt mit Linke: Website"
}






*Partycontact, kind and party 
*2013     
local letter "a b d e g h i k l"						
local party "a c d e f"
foreach num1 of numlist 2 3 4 5 6 7 {	//Waves
	foreach y of local party {			//Parties (a=Union, c=SPD, d=FDP, e=Gr𮥬 f=Linke)
	foreach x of local letter {			//Kinds of party contact
		gen b_parteikon_`x'_`y'_`num1'=.
		replace b_parteikon_`x'_`y'_`num1'=b_kp`num1'_421`x'`y'
		replace b_parteikon_`x'_`y'_`num1'=. if b_kp`num1'_421`x'`y'<0															
		}
	}
}

*label party contact, kind and party
foreach num1 of numlist 2 3 4 5 6 7 {		
	label var b_parteikon_a_a_`num1' "Parteikontakt mit Union: Wahlveranstaltung"
	label var b_parteikon_b_a_`num1' "Parteikontakt mit Union: Flugblätter/Email/SMS"
	label var b_parteikon_d_a_`num1' "Parteikontakt mit Union: Wahlwerbung, Fernsehen"
	label var b_parteikon_e_a_`num1' "Parteikontakt mit Union: Wahlwerbung, Radio"
	label var b_parteikon_g_a_`num1' "Parteikontakt mit Union: Wahlplakate"
	label var b_parteikon_h_a_`num1' "Parteikontakt mit Union: Wahlkampfstand"
	label var b_parteikon_i_a_`num1' "Parteikontakt mit Union: Soziales Netzwerk"
	label var b_parteikon_k_a_`num1' "Parteikontakt mit Union: Website"
	label var b_parteikon_l_a_`num1' "Parteikontakt mit Union: Geldspende"
	label var b_parteikon_a_c_`num1' "Parteikontakt mit SPD: Wahlveranstaltung"
	label var b_parteikon_b_c_`num1' "Parteikontakt mit SPD: Flugblätter/Email/SMS"
	label var b_parteikon_d_c_`num1' "Parteikontakt mit SPD: Wahlwerbung, Fernsehen"
	label var b_parteikon_e_c_`num1' "Parteikontakt mit SPD: Wahlwerbung, Radio"
	label var b_parteikon_g_c_`num1' "Parteikontakt mit SPD: Wahlplakate"
	label var b_parteikon_h_c_`num1' "Parteikontakt mit SPD: Wahlkampfstand"
	label var b_parteikon_i_c_`num1' "Parteikontakt mit SPD: Soziales Netzwerk"
	label var b_parteikon_k_c_`num1' "Parteikontakt mit SPD: Website"
	label var b_parteikon_l_c_`num1' "Parteikontakt mit SPD: Geldspende"
	label var b_parteikon_a_d_`num1' "Parteikontakt mit FDP: Wahlveranstaltung"
	label var b_parteikon_b_d_`num1' "Parteikontakt mit FDP: Flugblätter/Email/SMS"
	label var b_parteikon_d_d_`num1' "Parteikontakt mit FDP: Wahlwerbung, Fernsehen"
	label var b_parteikon_e_d_`num1' "Parteikontakt mit FDP: Wahlwerbung, Radio"
	label var b_parteikon_g_d_`num1' "Parteikontakt mit FDP: Wahlplakate"
	label var b_parteikon_h_d_`num1' "Parteikontakt mit FDP: Wahlkampfstand"
	label var b_parteikon_i_d_`num1' "Parteikontakt mit FDP: Soziales Netzwerk"
	label var b_parteikon_k_d_`num1' "Parteikontakt mit FDP: Website"
	label var b_parteikon_l_d_`num1' "Parteikontakt mit FDP: Geldspende"
	label var b_parteikon_a_e_`num1' "Parteikontakt mit Grüne Wahlveranstaltung"
	label var b_parteikon_b_e_`num1' "Parteikontakt mit Grüne Flugblätter/Email/SMS"
	label var b_parteikon_d_e_`num1' "Parteikontakt mit Grüne Wahlwerbung, Fernsehen"
	label var b_parteikon_e_e_`num1' "Parteikontakt mit Grüne Wahlwerbung, Radio"
	label var b_parteikon_g_e_`num1' "Parteikontakt mit Grüne Wahlplakate"
	label var b_parteikon_h_e_`num1' "Parteikontakt mit Grüne Wahlkampfstand"
	label var b_parteikon_i_e_`num1' "Parteikontakt mit Grüne Soziales Netzwerk"
	label var b_parteikon_k_e_`num1' "Parteikontakt mit Grüne Website"
	label var b_parteikon_l_e_`num1' "Parteikontakt mit Grüne Geldspende"
	label var b_parteikon_a_f_`num1' "Parteikontakt mit Linke: Wahlveranstaltung"
	label var b_parteikon_b_f_`num1' "Parteikontakt mit Linke: Flugblätter/Email/SMS"
	label var b_parteikon_d_f_`num1' "Parteikontakt mit Linke: Wahlwerbung, Fernsehen"
	label var b_parteikon_e_f_`num1' "Parteikontakt mit Linke: Wahlwerbung, Radio"
	label var b_parteikon_g_f_`num1' "Parteikontakt mit Linke: Wahlplakate"
	label var b_parteikon_h_f_`num1' "Parteikontakt mit Linke: Wahlkampfstand"
	label var b_parteikon_i_f_`num1' "Parteikontakt mit Linke: Soziales Netzwerk"
	label var b_parteikon_k_f_`num1' "Parteikontakt mit Linke: Website"
	label var b_parteikon_l_f_`num1' "Parteikontakt mit Linke: Geldspende"
}







forvalues num=2/6 {			//2009
egen a_kundgeb_new`num' = anycount(a_parteikon_a_?_`num'), values(1)
replace a_kundgeb_new`num' = . if a_kp`num'_400==99 | a_kp`num'_400==.
egen a_flu_new`num' = anycount(a_parteikon_b_?_`num'), values(1)
replace a_flu_new`num' = . if a_kp`num'_400==99 | a_kp`num'_400==.
egen a_mail_new`num' = anycount(a_parteikon_c_?_`num'), values(1)
replace a_mail_new`num' = . if a_kp`num'_400==99 | a_kp`num'_400==.
egen a_flumail_new`num' = rowmax(a_flu_new`num' a_mail_new`num')
egen a_fernsehen_new`num' = anycount(a_parteikon_d_?_`num'), values(1)
replace a_fernsehen_new`num' = . if a_kp`num'_400==99 | a_kp`num'_400==.
egen a_radio_new`num' = anycount(a_parteikon_e_?_`num'), values(1)
replace a_radio_new`num' = . if a_kp`num'_400==99 | a_kp`num'_400==.
egen a_plakat_new`num' = anycount(a_parteikon_g_?_`num'), values(1)
replace a_plakat_new`num' = . if a_kp`num'_400==99 | a_kp`num'_400==.
egen a_stand_new`num' = anycount(a_parteikon_h_?_`num'), values(1)
replace a_stand_new`num' = . if a_kp`num'_400==99 | a_kp`num'_400==.
egen a_website_new`num' = anycount(a_parteikon_k_?_`num'), values(1)
replace a_website_new`num' = . if a_kp`num'_400==99 | a_kp`num'_400==.
egen a_countcontact`num' = rowtotal(a_website_new`num' a_plakat_new`num' ///
	a_kundgeb_new`num' a_fernsehen_new`num' a_radio_new`num' a_stand_new`num' ///
	a_flumail_new`num'), missing
replace a_countcontact`num' = a_countcontact`num'/35
}


foreach num of numlist 7 {			//2009
egen a_kundgeb_new`num' = anycount(a_parteikon_a_?_`num'), values(1)
replace a_kundgeb_new`num' = . if a_kp`num'_401==99 | a_kp`num'_401==.
egen a_flu_new`num' = anycount(a_parteikon_b_?_`num'), values(1)
replace a_flu_new`num' = . if a_kp`num'_401==99 | a_kp`num'_401==.
egen a_mail_new`num' = anycount(a_parteikon_c_?_`num'), values(1)
replace a_mail_new`num' = . if a_kp`num'_401==99 | a_kp`num'_401==.
egen a_flumail_new`num' = rowmax(a_flu_new`num' a_mail_new`num')
egen a_fernsehen_new`num' = anycount(a_parteikon_d_?_`num'), values(1)
replace a_fernsehen_new`num' = . if a_kp`num'_401==99 | a_kp`num'_401==.
egen a_radio_new`num' = anycount(a_parteikon_e_?_`num'), values(1)
replace a_radio_new`num' = . if a_kp`num'_401==99 | a_kp`num'_401==.
egen a_plakat_new`num' = anycount(a_parteikon_g_?_`num'), values(1)
replace a_plakat_new`num' = . if a_kp`num'_401==99 | a_kp`num'_401==.
egen a_stand_new`num' = anycount(a_parteikon_h_?_`num'), values(1)
replace a_stand_new`num' = . if a_kp`num'_401==99 | a_kp`num'_401==.
egen a_website_new`num' = anycount(a_parteikon_k_?_`num'), values(1)
replace a_website_new`num' = . if a_kp`num'_401==99 | a_kp`num'_401==.
egen a_countcontact`num' = rowtotal(a_website_new`num' a_plakat_new`num' ///
	a_kundgeb_new`num' a_fernsehen_new`num' a_radio_new`num' a_stand_new`num' ///
	a_flumail_new`num'), missing
replace a_countcontact`num' = a_countcontact`num'/35
}






forvalues num=2/7 {
egen b_kundgeb`num' = anycount(b_parteikon_a_?_`num'), values(1)
replace b_kundgeb`num' = . if b_parteikon_a_a_`num'>1 & ///
	b_parteikon_a_c_`num'>1 & b_parteikon_a_d_`num'>1 &  ///
	b_parteikon_a_e_`num'>1 & b_parteikon_a_f_`num'>1 
egen b_flumail`num' = anycount(b_parteikon_b_?_`num'), values(1)
replace b_flumail`num' = . if b_parteikon_b_a_`num'>1 & ///
	b_parteikon_b_c_`num'>1 & b_parteikon_b_d_`num'>1 &  ///
	b_parteikon_b_e_`num'>1 & b_parteikon_b_f_`num'>1 
egen b_fernsehen`num' = anycount(b_parteikon_d_?_`num'), values(1)
replace b_fernsehen`num' = . if b_parteikon_d_a_`num'>1 & ///
	b_parteikon_d_c_`num'>1 & b_parteikon_d_d_`num'>1 &  ///
	b_parteikon_d_e_`num'>1 & b_parteikon_d_f_`num'>1 
egen b_radio`num' = anycount(b_parteikon_e_?_`num'), values(1)
replace b_radio`num' = . if b_parteikon_e_a_`num'>1 & ///
	b_parteikon_e_c_`num'>1 & b_parteikon_e_d_`num'>1 &  ///
	b_parteikon_e_e_`num'>1 & b_parteikon_e_f_`num'>1 
egen b_plakat`num' = anycount(b_parteikon_g_?_`num'), values(1)
replace b_plakat`num' = . if b_parteikon_g_a_`num'>1 & ///
	b_parteikon_g_c_`num'>1 & b_parteikon_g_d_`num'>1 &  ///
	b_parteikon_g_e_`num'>1 & b_parteikon_g_f_`num'>1 
egen b_stand`num' = anycount(b_parteikon_h_?_`num'), values(1)
replace b_stand`num' = . if b_parteikon_h_a_`num'>1 & ///
	b_parteikon_h_c_`num'>1 & b_parteikon_h_d_`num'>1 &  ///
	b_parteikon_h_e_`num'>1 & b_parteikon_h_f_`num'>1 
egen b_website`num' = anycount(b_parteikon_k_?_`num'), values(1)
replace b_website`num' = . if b_parteikon_k_a_`num'>1 & ///
	b_parteikon_k_c_`num'>1 & b_parteikon_k_d_`num'>1 &  ///
	b_parteikon_k_e_`num'>1 & b_parteikon_k_f_`num'>1 
egen b_countcontact`num' = rowtotal(b_website`num' b_plakat`num' ///
	b_kundgeb`num' b_fernsehen`num' b_radio`num' b_stand`num' ///
	b_flumail`num'), missing
replace b_countcontact`num' = b_countcontact`num'/35
}

fre b_countcontact?


* Campaign contacts with the different parties
foreach welle of numlist 2/6 {
foreach party of numlist 1/5 {
egen a_parteikon_`party'`welle' = anycount(a_kp`welle'_420a_`party' ///
	a_kp`welle'_420d_`party' a_kp`welle'_420e_`party'  ///
	 a_kp`welle'_420g_`party' ///
	a_kp`welle'_420h_`party' a_kp`welle'_420k_`party'), ///
	values(1)
replace a_parteikon_`party'`welle' = a_parteikon_`party'`welle'+1 /// here again Flumail
	if a_kp`welle'_420b_`party'==1 | a_kp`welle'_420c_`party'==1
replace a_parteikon_`party'`welle' = . if a_kp`welle'_400==99 | ///
	a_kp`welle'_400==.
replace a_parteikon_`party'`welle' = a_parteikon_`party'`welle'/7

}
}



foreach welle of numlist 7 {
foreach party of numlist 1/5 {
egen a_parteikon_`party'`welle' = anycount(a_kp`welle'_420a_`party' ///
	a_kp`welle'_420d_`party' a_kp`welle'_420e_`party'  ///
	 a_kp`welle'_420g_`party' ///
	a_kp`welle'_420h_`party' a_kp`welle'_420k_`party'), ///
	values(1)
replace a_parteikon_`party'`welle' = a_parteikon_`party'`welle'+1 /// here again Flumail
	if a_kp`welle'_420b_`party'==1 | a_kp`welle'_420c_`party'==1
replace a_parteikon_`party'`welle' = . if a_kp`welle'_401==99 | ///
	a_kp`welle'_401==.
replace a_parteikon_`party'`welle' = a_parteikon_`party'`welle'/7

}
}





foreach welle of numlist 2/7 {		//rename variables
rename a_parteikon_1`welle' a_parteikon_cdu`welle'
rename a_parteikon_2`welle' a_parteikon_spd`welle'
rename a_parteikon_3`welle' a_parteikon_fdp`welle'
rename a_parteikon_4`welle' a_parteikon_gru`welle'
rename a_parteikon_5`welle' a_parteikon_link`welle'
}


sum a_countcontact2
lookfor b_kp?_421hd

foreach welle of numlist 2/7 {
foreach party in a c d e f {
egen b_parteikon_`party'`welle' = anycount(b_kp`welle'_421a`party' ///
	b_kp`welle'_421b`party'			///
	b_kp`welle'_421d`party' b_kp`welle'_421e`party'  ///
	 b_kp`welle'_421g`party' ///
	b_kp`welle'_421h`party' b_kp`welle'_421k`party'), values(1)
replace b_parteikon_`party'`welle' = . if b_kp`welle'_421y>1
replace b_parteikon_`party'`welle' = b_parteikon_`party'`welle'/7
}	
}

fre b_kp4_421y

sum b_parteikon_?4
sum b_countcontact4


foreach welle of numlist 2/7 {		//rename variables
rename b_parteikon_a`welle' b_parteikon_cdu`welle'
rename b_parteikon_c`welle' b_parteikon_spd`welle'
rename b_parteikon_d`welle' b_parteikon_fdp`welle'
rename b_parteikon_e`welle' b_parteikon_gru`welle'
rename b_parteikon_f`welle' b_parteikon_link`welle'
}

* Campaign contact with a particular party as dummy
foreach year in a b {
foreach party in cdu spd fdp gru link {
foreach welle of numlist 2/7 {
gen `year'_dcontact_`party'`welle' = 0 ///
	if `year'_parteikon_`party'`welle'==0
replace `year'_dcontact_`party'`welle' = 1 ///
	if `year'_parteikon_`party'`welle'>0 & `year'_parteikon_`party'`welle'~=.
}
}
}

tab a_dcontact_cdu6 a_parteikon_cdu6, m

//sum a_oeff1-b_parteikon_link7	//check value range for all variables

*--------------------------------------------------
* Reception of specific campaign media/events
*--------------------------------------------------

* Dummy indicating reception/non-reception of TV-duel:
fre a_kp6_1800
gen a_duell6 = .
replace a_duell6 = 0 if a_kp6_1800 == 3
replace a_duell6 = 1 if a_kp6_1800 == 1 | a_kp6_1800 == 2
lab var a_duell6 "TV-Duell 2009 gesehen"
lab define jn 0 "nein" 1 "ja"
label val a_duell6 jn
tab a_kp6_1800 a_duell6, m

gen b_duell5 = .
replace b_duell5 = 0 if b_kp5_1800 == 3
replace b_duell5 = 1 if b_kp5_1800 == 1 | b_kp5_1800 == 2
lab var b_duell5 "TV-Duell 2013 gesehen"
label val b_duell5 jn
tab b_kp5_1800 b_duell5, m

* Dummy indicating reception/non-reception of election arena with Merkel(only 2013):
gen b_arena_merk6 = .
replace b_arena_merk6 = 0 if b_kp6_2980a == 3
replace b_arena_merk6 = 1 if b_kp6_2980a == 1 | b_kp6_2980a == 2
lab var b_arena_merk6 "Wahlarena mit Merkel gesehen"
label val b_arena_merk6 jn
tab b_arena_merk6 b_kp6_2980a, m

* Dummy indicating reception/non-reception of election arena with Steinbrück(only 2013):
gen b_arena_stein6 = .
replace b_arena_stein6 = 0 if b_kp6_2980b == 3
replace b_arena_stein6 = 1 if b_kp6_2980b == 1 | b_kp6_2980b == 2
lab var b_arena_stein6 "Wahlarena mit Steinbrück gesehen"
label val b_arena_stein6 jn

* Dummy indicating usage/non-usage of Wahl-O-Mat (only 2013):
foreach welle of numlist 5/7 {
gen b_wahlomat`welle' = .
replace b_wahlomat`welle' = 0 ///
	if b_kp`welle'_3490 == 2 | b_kp`welle'_3490==.p 
replace b_wahlomat`welle' = 1 if b_kp`welle'_3490 == 1 | b_kp`welle'_3490==.c
lab var b_wahlomat`welle' "Wahl-O-mat benutzt"
label val b_wahlomat`welle' jn
}

gen b_wahlomat_anytime = b_wahlomat5==1 | b_wahlomat6==1 | ///
	b_wahlomat7==1
replace b_wahlomat_anytime = . if b_wahlomat5==. & b_wahlomat6==. ///
	& b_wahlomat7==.
	
tab b_wahlomat7 b_kp7_3490, m	
list b_wahlomat_anytime b_wahlomat?



